package ying;/**
 * ClassName: ServletContextDemo03
 * Package: ying
 * Description:
 *
 * @Author 刘英杰
 * @Create 2024/9/29 14:15
 * @Version 1.0
 */

/**
 * ServletContext中的方法
 *     public void setAttribute(String name, Object object):向ServletContext对象中存入key=value键值对
 */

import jakarta.servlet.*;
import jakarta.servlet.http.*;
import jakarta.servlet.annotation.*;

import java.io.IOException;

@WebServlet("/context03")
public class ServletContextDemo03 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        getServletContext().setAttribute("id", "123");
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }
}
